﻿
$(document).ready(function () {
    // Find rv
    $('#btnSearch').click(function () {
        var q = $('#keywords').val();
        var cat = $('#category').val();
        if (q.toLowerCase() != 'nhập từ khóa' && q != '') {
            q = q.replace(/\s/g, "+");
            window.location = '/tim-kiem?q=' + q + '&cat=' + cat;
        }
        return false;
    });

    $('#local input').bind('keypress', function (e) {
        if (e.keyCode == 13) {
            // Enter pressed... do anything here...
            $('#btnSearch').click();
        }
    });

    // Notification
    $('.notice').click(function () {
        if ($('#advnotice').css("display") == "none")
            $('#advnotice').css("display", "block");
        else
            $('#advnotice').css("display", "none");
    });
});

// Progress Bar
function openProcess() {
    $.fancybox($('#showdialog'), {
        padding: 0,
        closeBtn: false,
        helpers: {
            overlay: {
                opacity: 0.2,
                css: {
                    'background-color': '#EFEFEE'
                }
            }
        },
        beforeClose: function () {
            return false;
        }
    });
    $('.fancybox-skin').show();
    $('#fancybox-overlay').show();
}
function hideProcess() {
    $('#showdialog').hide();
    $('.fancybox-skin').hide();
    $('#fancybox-overlay').hide();
}

// Marquee
$(function () {
    // basic version is: $('div.demo marquee').marquee() - but we're doing some sexy extras

    $('div.marquee marquee').marquee('pointer').mouseover(function () {
        $(this).trigger('stop');
    }).mouseout(function () {
        $(this).trigger('start');
    }).mousemove(function (event) {
        if ($(this).data('drag') == true) {
            this.scrollLeft = $(this).data('scrollX') + ($(this).data('x') - event.clientX);
        }
    }).mousedown(function (event) {
        $(this).data('drag', true).data('x', event.clientX).data('scrollX', this.scrollLeft);
    }).mouseup(function () {
        $(this).data('drag', false);
    });
});
